using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// 用户第一次启动项目需要的操作 - 添加引用
// 参照 https://mp.weixin.qq.com/s/RqMlRFxBmKwngIJkdjMOZw 【2 - 添加对 ProjectPenguin.dll .. 的引用】
// 引用添加成功后以下using就不会报错。
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
using ProjectPenguin.Cards; // Y-GAMA的主框架类库
using NSGeo.Geometry; // 可选 图形数据描述依赖类库
using NSFramework; // 可选 GAMA结构模型类库

using ProjectPenguin.Cards.ProcessorCardHelpers;

namespace UserDeck
{
    public class PolylineSplitCard : ProcessorCardBase
    {
        public PolylineSplitCard() : base("分解多段线", "分解多段线", "分解多段线", "UserDeck", "几何运算") { }
        static Guid _guid = Guid.Parse("{9C7F1004-DE2A-45CE-8C36-1CB85A9FE0EA}");
        public override Guid CardGuid => _guid;

        protected override void AddInputSideDataCards(IDataCardEmbedmentHelper helper)
        {
            helper.AddWellKnownTypeOfDataCard(typeof(Polyline), "多段线", "多段线", "多段线", ProjectPenguin.Cards.Enums.DataProcessingMode.OneByOne);
        }

        protected override void AddOutputSideDataCards(IDataCardEmbedmentHelper helper)
        {
            helper.AddWellKnownTypeOfDataCard(typeof(Line), "直线", "直线", "多个直线", ProjectPenguin.Cards.Enums.DataProcessingMode.ListByList);
        }

        public override void Build(IDataDelivery idd)
        {
            Polyline pl = new Polyline();
            if (!idd.GetDataItem(0, ref pl) || pl == null) return;
            idd.SetDataList(0, pl.GetSegments());
        }
    }
}
